@isTest
private class test_CXGCallMainScript
{
 /* 
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
    static testMethod void myUnitTest() 
    {
     Profile p = [select id from profile where name='System Administrator']; 
     User u = new User(alias = 'sysadmin', email='sysadmin@accenture.com',emailencodingkey='UTF-8', lastname='Testing12', languagelocalekey='en_US',       localesidkey='en_US', profileid = p.Id,timezonesidkey='Asia/Calcutta', username='testadmin123@testorg.com'); 
     Insert u;
     User u1 = new User(alias = 'sysadmin', email='sysadmin1@accenture.com',ManagerId=u.Id,emailencodingkey='UTF-8', lastname='Testing123', languagelocalekey='en_US',       localesidkey='en_US', profileid = p.Id,timezonesidkey='Asia/Calcutta', username='testadmin1234@testorg.com'); 
     Insert u1;
     
     
     Account acct = New Account();
     acct.Name='TestAccount';
     acct.CSS_CustomerID__c='9171367619';
     Insert acct;//inserting  a Test account
     
     Campaign parentcamp = New Campaign();
     parentcamp.Name='Parent Campaign';
     parentcamp.StartDate=Date.Today();
     parentcamp.EndDate=Date.Today()+14;
     Insert parentcamp;//Inserting  a Parent campaign
     
     Campaign camp= New Campaign();
     camp.Name='Campaign Wave1';
     camp.ParentId=parentcamp.Id;
     camp.StartDate=Date.Today();
     Camp.EndDate=Date.Today()+7;
     Insert camp;
     ID CxGEventRecordtypID = RecordTypeHelper.GetRecordTypeIdByDevName('Event', 'CXG_Record_Type');
     ID CxGTaskRecordTypeID = RecordTypeHelper.GetRecordTypeIdByDevName('Task', 'CXG_Task_Layout');
     CXG_Campaign_Accounts__c campaignmember= New CXG_Campaign_Accounts__c();
     campaignmember.Campaign__c=camp.Id;
     campaignmember.Customer__c=acct.Id;
     Insert campaignmember;
     Script__c sct= New Script__c();
     sct.Name='Test Script';
     Insert sct;
     Issue_Subissue__c issu= New Issue_Subissue__c();
     issu.Name='Test Issue';
     issu.Script__c=sct.Id;
     issu.Issue__c='Issue';
     issu.Subissue__c='Sub-Issue';
     Insert issu;
     String text='Test notes';
     Event evnt= New Event();
     evnt.WhatId=acct.Id;
     evnt.StartDateTime=DateTime.Now();
     DateTime dt=evnt.StartDateTime;
     evnt.EndDateTime=dt.addMinutes(30);
     evnt.Description='test';
     evnt.RecordTypeId=CxGEventRecordtypID;
     evnt.Call_Back_Scheduled__c=True;
     evnt.CXG_Account__c=True;
     evnt.Issue_Identified__c=True;
     evnt.Sub_Issue__c=issu.Issue__c;
     evnt.Issue__c=issu.Issue__c;
     evnt.OwnerId=u.Id;
     evnt.Disposition__c='Disposition';
     evnt.Call_Resolutions__c='TESTCallRESOLUTION';
     evnt.Campaign__c='https://test.salesforce.com';
     Insert evnt;
     evnt.Owner_Manager__c='Testing123';
     Update evnt;
     Task tsk = New Task(); 
     tsk.WhatId=acct.Id; 
     tsk.Disposition__c='Disposition';
     tsk.Call_Resolutions__c='Test';
     tsk.ActivityDate=Date.Today();
     tsk.Attempt_Date__c=DateTime.Now();
     tsk.Status='New';
     tsk.Priority='Normal';
     tsk.RecordTypeId=CxGTaskRecordTypeID;
     tsk.Description='Test';
     tsk.Campaign_Member_ID__c=campaignmember.Name;
     tsk.Subject='Test Subject';
     tsk.Issue_Identified__c=True;
     tsk.Sub_Issue__c=issu.Issue__c;
     tsk.Issue__c=issu.Issue__c;
     tsk.CXG_Account__c=True; 
     Insert tsk; 
     task insrtdTask = [select Server_URL__c from task where id = :tsk.id];   
     tsk.Campaign__c='https://test.salesforce.com';  
     update tsk;
     Task tsk1 = New Task(); 
     tsk1.WhatId=campaignmember.Id; 
     tsk1.Disposition__c='Disposition';
     tsk1.ActivityDate=Date.Today();
     tsk1.Attempt_Date__c=DateTime.Now();
     tsk1.Status='New';
     tsk1.Priority='Normal';
     tsk1.Subject='Test Subject';
     tsk1.Description='Test1';
     tsk1.Issue_Identified__c=True;
     tsk1.Call_Resolutions__c='Test123';
     tsk1.Sub_Issue__c=issu.Issue__c;
     tsk1.Issue__c=issu.Issue__c;
     tsk1.RecordTypeId=CxGTaskRecordTypeID;
     tsk1.Campaign_Member_ID__c=campaignmember.Name;
     tsk1.CXG_Account__c=True; 
     insert tsk1;
     tsk1.Campaign__c='https://test.salesforce.com'; 
     update tsk1;
     Notes__c notes = New Notes__c(); 
     notes.Account__c=acct.Id; 
     notes.Notes__c='Test Notes'; 
     notes.Note__c='Salesforce'; 
     notes.Date__c=DateTime.Now();
     notes.Disposition__c=tsk.Disposition__c;
     Insert notes; 
          
     ApexPages.CurrentPage().getParameters().put('actid',acct.Id);
     ApexPages.CurrentPage().getParameters().put('campname',camp.Id);
     ApexPages.CurrentPage().getParameters().put('cmid',campaignmember.Id);
     ApexPages.CurrentPage().getParameters().put('issue',issu.Issue__c);
     ApexPages.CurrentPage().getParameters().put('subissue',issu.Subissue__c);
     
     ApexPages.StandardController sc = new ApexPages.StandardController(evnt); 
     CXGMainScript cms = new CXGMainScript(sc);
     cms.createNote();
     cms.onclickaction();
     cms.getFlag(); 
     cms.getItems();
     cms.getScriptsteps();
     cms.getCallResolution();
     cms.getDisposition();
     cms.getEvent();
     
   }
 }